{% extends "base.html" %}
{% load i18n %}

{% block head-css-ext %}
    <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/jquery.autocomplete.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/blue/style.css" media="print, projection, screen" />
{% endblock %}

{% block head-js-ext %}
    <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.js"></script>
    <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.bgiframe.js"></script>
    <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.autocomplete.js"></script>
    <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.tablesorter.js"></script>
    <script type="text/javascript" src="{{MEDIA_URL}}js/date.format.js"></script>
{% endblock %}

{% block head-js-embedded %}
    <script type="text/javascript">
      var tmp;
      $(document).ready(function(){
        
        $("#clientes").tablesorter({widthFixed: true,  widgets: ['zebra'], headers: { 0:{sorter: false}, 1:{sorter: false}, 4:{sorter: false}, 5:{sorter: false} } }) ;
 
        $("select#tipoprestamo").change(function(){
          $.getJSON("/ajax/buscarprestamo/"+$(this).val()+"/", function(data){
            var options = '';
            for (var i = 0; i < data.length; i++)
            {
              var fecha = new Date(data[i].fields['fecha']);
                        
              options += '<tr align="center">' +
                            '<td>' + data[i].fields['empresario'] + '</td>' +
                            '<td>' + data[i].fields['producto'] + '</td>' +
                            '<td>' + data[i].fields['cantidad'] + '</td>' +
                            '<td>' + fecha.format("dd mmm yyyy") + '</td>' +
                            '<td>' + data[i].fields['tipo_prestamo'] + '</td>' +
                             '<td>' + '<input type="checkbox" name="devolver_prestamo" value="' + parseInt(data[i].pk) + '" id="event">' + '</td>' +                                  
                          '</tr>';            
            }
            $("#clientes tbody").html(options);                  
          });
        });       
      });     
    </script>
{% endblock %}


{% block content-box1 %}
    <!--<label for="buscarproductos">Producto: </label>-->
    <!--<input type="text" id="buscarproductos" name="buscarproductos" size="35">-->
    <!--<br><br>-->
    <!--<label for="buscarcliente">Cliente: </label>-->
    <!--<input type="text" id="buscarcliente" name="buscarcliente" size="35">-->
    <!--<br><br>-->
    
    <select id="tipoprestamo" name="tipoprestamo">
        <option value="" selected="selected">-----------------------</option>
        <option value="3">Prestamo de Empresario</option>
        <option value="4">Prestamo a Empresario</option>
    </select>
    <form method="POST" id="testform">
      <table id="clientes" class="tablesorter">
        <thead>
          <tr align="center">
            <th>Empresario&nbsp;&nbsp;&nbsp;</th>
            <th>Producto&nbsp;&nbsp;&nbsp;</th>
            <th>Cantidad&nbsp;&nbsp;&nbsp;&nbsp;</th>
            <th>Fecha&nbsp;&nbsp;&nbsp;&nbsp;</th>
            <th>Tipo de Prestamo</th>
            <th>Marcar para devolución</th>
          </tr>            
        </thead>   
        <tbody>
        </tbody>
      </table>
      <input type="submit" name="eliminarnotas" id="devolver_prestamo" value="Aplicar Devolucion"></p>
    </form>
  
{% endblock %}



